"""
实战三：模拟微信抢红包
"""

from random import random, shuffle
from decimal import Decimal

total = Decimal(input('请输入要装入红包的金额（元）: '))
account= int(input('请输入红包的个数: '))

remainMoney = total
remainAccount= Decimal(account)
min=0.01

list=[]
for i in range(account):
  # money = Decimal(money) - Decimal(total)
  # current = Decimal(Decimal(random())*money/10).quantize(Decimal("0.00"))
  # total += Decimal(current)

  if i == len(range(account))-1:
    ranNum = remainMoney
  else:
    ranNum =Decimal(Decimal(random())*2*remainMoney/remainAccount).quantize(Decimal('0.00'))
    if ranNum<0.01:
      ranNum = min
    remainAccount = Decimal(account - i)
    remainMoney = remainMoney - ranNum 
  # print(i, ranNum)
  # print(remainAccount, remainMoney)
  list.append(ranNum)
  
  print(f'第{i+1}个红包:, {ranNum}元')

  shuffle(list)
print('=================================')
j = 1
for i in list:
    print(f'第{j}个红包, {i}元')
    j = j + 1

maxValue = max(list)
print(f'抢到最多的是: {maxValue}元')